package com.zgt.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zgt.dao.AdminDao;
import com.zgt.model.Admin;
import com.zgt.service.AdminService;
import com.zgt.util.Page;

@Service("adminService")
public class AdminServiceImpl implements AdminService {

	private AdminDao adminDao;

	public AdminDao getAdminDao() {
		return adminDao;
	}

	@Resource(name = "adminDao")
	public void setAdminDao(AdminDao adminDao) {
		this.adminDao = adminDao;
	}

	public boolean addAdmin(Admin admin) {
		return adminDao.saveAdmin(admin);
	}

	public void changePassword(Admin admin) {
		adminDao.changePassword(admin);
	}

	public Admin checkLogin(Admin admin) {
		return adminDao.checkLogin(admin);
	}

	public void deleteAdminByid(int id) {
		adminDao.deleteAdminByid(id);
	}

	public Page admins(Page page) {
		
		page.setAllRow(adminDao.getCount());
		
		List admins = adminDao.admins(page.getOffset(),page.getPageSize());
		page.setPageResult(admins);
		
		return page;
	}

	public Admin getAdminByid(int id) {
		return adminDao.getAdminByid(id);
	}

}
